<div>
    <div class="row justify-content-center">
        <div class="col-md-4">
            <h1>重置密码</h1>

            <div class="alert alert-danger" *ngIf="initialized && !key">
                <strong>密码重置密钥缺失。</strong>
            </div>

            <div class="alert alert-warning" *ngIf="key && !success">
                <span>请选择新密码</span>
            </div>

            <div class="alert alert-danger" *ngIf="error">
                <span>您的密码无法重置。请记住密码重置请求仅在24小时内有效。</span>
            </div>

            <div class="alert alert-success" *ngIf="success">
                <span><strong>您的密码已重置。</strong> 请 </span>
                <a class="alert-link" (click)="login()">登录</a>。
            </div>

            <div class="alert alert-danger" *ngIf="doNotMatch">
                密码和确认密码不匹配！
            </div>

            <div *ngIf="key && !success">
                <form name="form" role="form" (ngSubmit)="finishReset()" [formGroup]="passwordForm">
                    <div class="form-group">
                        <label class="form-control-label" for="newPassword">新密码</label>
                        <input type="password" class="form-control" id="newPassword" name="newPassword"
                               placeholder="新密码"
                               formControlName="newPassword" #newPassword>

                        <div *ngIf="passwordForm.get('newPassword')!.invalid && (passwordForm.get('newPassword')!.dirty || passwordForm.get('newPassword')!.touched)">
                            <small class="form-text text-danger"
                                   *ngIf="passwordForm.get('newPassword')?.errors?.required">
                                密码是必填项。
                            </small>

                            <small class="form-text text-danger"
                                   *ngIf="passwordForm.get('newPassword')?.errors?.minlength">
                                密码至少需要4个字符。
                            </small>

                            <small class="form-text text-danger"
                                   *ngIf="passwordForm.get('newPassword')?.errors?.maxlength">
                                密码不能超过50个字符。
                            </small>
                        </div>

                        <jhi-password-strength-bar [passwordToCheck]="passwordForm.get('newPassword')!.value"></jhi-password-strength-bar>
                    </div>

                    <div class="form-group">
                        <label class="form-control-label" for="confirmPassword">确认新密码</label>
                        <input type="password" class="form-control" id="confirmPassword" name="confirmPassword"
                               placeholder="确认新密码"
                               formControlName="confirmPassword">

                        <div *ngIf="passwordForm.get('confirmPassword')!.invalid && (passwordForm.get('confirmPassword')!.dirty || passwordForm.get('confirmPassword')!.touched)">
                            <small class="form-text text-danger"
                                   *ngIf="passwordForm.get('confirmPassword')?.errors?.required">
                                确认密码是必填项。
                            </small>

                            <small class="form-text text-danger"
                                   *ngIf="passwordForm.get('confirmPassword')?.errors?.minlength">
                                确认密码至少需要4个字符。
                            </small>

                            <small class="form-text text-danger"
                                   *ngIf="passwordForm.get('confirmPassword')?.errors?.maxlength">
                                确认密码不能超过50个字符。
                            </small>
                        </div>
                    </div>

                    <button type="submit" [disabled]="passwordForm.invalid" class="btn btn-primary">重置密码</button>
                </form>
            </div>
        </div>
    </div>
</div>
